home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / libraries / pm.m < prev   
Encoding:
Text File  |  2002-10-28  |  16.1 KB  |  284 lines

  1. /*
  2. //      $VER: pm.h 10.05 (11.11.00)
  3. //
  4. //      Library base, tags and macro definitions
  5. //      for popupmenu.library.
  6. //
  7. //      ©1996-2000 Henrik Isaksson
  8. //      All Rights Reserved.
  9. //
  10. //      Changes:
  11. //
  12. //      9.00    New PopupMenu structure.
  13. //              Several new tags and updated macros.
  14. //      9.01    Added PM_HintBox
  15. //      10.0    Added PM_Toggle, PM_ExcludeShared
  16. //              Added macro PMMXItem
  17. //              Added two flags, PM_CHECKIT and PM_CHECKED
  18. //      10.05   Changed the PopupMenu structure a bit.
  19. //              Added typedef for PopupMenu.
  20. //              Added american english equalients for some tags.
  21. //
  22. */
  23.  
  24. MODULE 'exec/libraries'
  25. MODULE 'utility/tagitem'
  26. MODULE 'intuition/classusr','intuition/classes'
  27.  
  28. /*
  29. // Tags passed to PM_OpenPopupMenuA and PM_FilterIMsgA
  30. */
  31.  
  32. #define PM_Menu                 (TAG_USER+4)    /* (struct PopupMenu *) Pointer to menulist initialized by MakeMenu()           */
  33. #define PM_Top                  (TAG_USER+12)   /* (LONG) Top (Y) position                                                      */
  34. #define PM_Left                 (TAG_USER+13)   /* (LONG) Left (X) position                                                     */
  35. #define PM_Code                 (TAG_USER+14)   /* (UWORD) Obsolete.                                                            */
  36. #define PM_Right                (TAG_USER+15)   /* (LONG) X position relative to right edge                                     */
  37. #define PM_Bottom               (TAG_USER+16)   /* (LONG) Y position relative to bottom edge                                    */
  38. #define PM_MinWidth             (TAG_USER+17)   /* (LONG) Minimum width                                                         */
  39. #define PM_MinHeight            (TAG_USER+18)   /* (LONG) Minimum height                                                        */
  40. #define PM_ForceFont            (TAG_USER+19)   /* (struct TextFont *tf) Use this font instead of user preferences.             */
  41. #define PM_PullDown             (TAG_USER+90)   /* (BOOL) Turn the menu into a pulldown menu.                                   */
  42. #define PM_MenuHandler          (TAG_USER+91)   /* (struct Hook *) Hook that is called for each selected item, after the        */
  43.                                                 /* menu has been closed. This tag turns on MultiSelect.                         */
  44. #define PM_AutoPullDown         (TAG_USER+92)   /* (BOOL) Automatic pulldown menu. (PM_FilterIMsg only)                         */
  45. #define PM_LocaleHook           (TAG_USER+93)   /* (struct Hook *) Locale "GetString()" hook. (Not yet implemented)             */
  46. #define PM_CenterScreen         (TAG_USER+94)   /* (BOOL) Center menu on the screen                                             */
  47. #define PM_UseLMB               (TAG_USER+95)   /* (BOOL) Left mouse button should be used to select an item                    */
  48.                                                 /* (right button selects multiple items)                                        */
  49. #define PM_DRIPensOnly          (TAG_USER+96)   /* (BOOL) Only use the screen's DRI pens, revert to system images if necessary. */
  50.                                                 /* Use with care as it overrides the user's prefs!                              */
  51. #define PM_HintBox              (TAG_USER+97)   /* (BOOL) Close the menu when the mouse is moved.                               */
  52.  
  53. /*
  54. // Tags passed to MakeItem
  55. */
  56.  
  57. #define PM_Title                (TAG_USER+20)   /* (STRPTR) Item title                                                          */
  58. #define PM_UserData             (TAG_USER+21)   /* (void *) Anything, returned by OpenPopupMenu when this item is selected      */
  59. #define PM_ID                   (TAG_USER+22)   /* (ULONG) ID number, if you want an easy way to access this item later         */
  60. #define PM_CommKey              (TAG_USER+47)   /* (char) Keyboard shortcut for this item.                                      */
  61. #define PM_TitleID              (TAG_USER+49)   /* (ULONG) Locale string ID                                                     */
  62. #define PM_Object               (TAG_USER+43)   /* (Object *) BOOPSI object with the abillity to render this item               */
  63.  
  64. /* Submenu & Layout tags */
  65. /* PM_Sub & PM_Members are mutally exclusive */
  66. #define PM_Sub                  (TAG_USER+23)   /* (PopupMenu *) Pointer to submenu list (from PM_MakeMenu)                     */
  67. #define PM_Members              (TAG_USER+65)   /* (PopupMenu *) Members for this group (list created by PM_MakeMenu)           */
  68. #define PM_LayoutMode           (TAG_USER+64)   /* (ULONG) Layout method (PML_Horizontal / PML_Vertical)                        */
  69.  
  70. /* Text attributes */
  71. #define PM_FillPen              (TAG_USER+26)   /* (BOOL) Make the item appear in FILLPEN                                       */
  72. #define PM_Italic               (TAG_USER+29)   /* (BOOL) Italic text                                                           */
  73. #define PM_Bold                 (TAG_USER+30)   /* (BOOL) Bold text                                                             */
  74. #define PM_Underlined           (TAG_USER+31)   /* (BOOL) Underlined text                                                       */
  75. #define PM_ShadowPen            (TAG_USER+34)   /* (BOOL) Draw text in SHADOWPEN                                                */
  76. #define PM_ShinePen             (TAG_USER+35)   /* (BOOL) Draw text in SHINEPEN                                                 */
  77. #define PM_Centre               (TAG_USER+36)   /* (BOOL) Center the text of this item                                          */
  78. #define PM_Center               PM_Centre       /* American version... */
  79. #define PM_TextPen              (TAG_USER+45)   /* (ULONG) Pen number for text colour of this item                              */
  80. #define PM_Shadowed             (TAG_USER+48)   /* (BOOL) Draw a shadow behind the text                                         */
  81.  
  82. /* Other item attributes */
  83. #define PM_TitleBar             (TAG_USER+32)   /* (BOOL) Horizontal separator bar                                              */
  84. #define PM_WideTitleBar         (TAG_USER+33)   /* (BOOL) Same as above, but full width                                         */
  85. #define PM_NoSelect             (TAG_USER+25)   /* (BOOL) Make the item unselectable (without visual indication)                */
  86. #define PM_Disabled             (TAG_USER+38)   /* (BOOL) Disable an item                                                       */
  87. #define PM_Hidden               (TAG_USER+63)   /* (BOOL) This item is not to be drawn (nor used in the layout process)         */
  88.  
  89. /* Images & Icons */
  90. #define PM_ImageSelected        (TAG_USER+39)   /* (struct Image *) Image when selected, title will be rendered on top it       */
  91. #define PM_ImageUnselected      (TAG_USER+40)   /* (struct Image *) Image when unselected                                       */
  92. #define PM_IconSelected         (TAG_USER+41)   /* (struct Image *) Icon when selected                                          */
  93. #define PM_IconUnselected       (TAG_USER+42)   /* (struct Image *) Icon when unselected                                        */
  94.  
  95. /* Check/MX items */
  96. #define PM_Checkit              (TAG_USER+27)   /* (BOOL) Leave space for a checkmark                                           */
  97. #define PM_Checked              (TAG_USER+28)   /* (BOOL) Make this item is checked                                             */
  98. #define PM_AutoStore            (TAG_USER+44)   /* (BOOL *) Pointer to BOOL reflecting the current state of the item            */
  99. #define PM_Exclude              (TAG_USER+37)   /* (PM_IDLst *) Items to unselect or select when this gets selected             */
  100. #define PM_ExcludeShared        (TAG_USER+101)  /* (BOOL) Used if the list is shared between two or more items                  */
  101. #define PM_Toggle               (TAG_USER+100)  /* (BOOL) Enable/disable toggling of check/mx items. Default: TRUE              */
  102.  
  103. /* Dynamic construction/destruction */
  104. #define PM_SubConstruct         (TAG_USER+61)   /* (struct Hook *) Constructor hook for submenus. Called before menu is opened. */
  105. #define PM_SubDestruct          (TAG_USER+62)   /* (struct Hook *) Destructor hook for submenus. Called after menu has closed.  */
  106.  
  107. /* Special/misc. stuff */
  108. #define PM_UserDataString       (TAG_USER+46)   /* (STRPTR) Allocates memory and copies the string to UserData.                 */
  109. #define PM_Flags                (TAG_USER+24)   /* (UlONG) For internal use                                                     */
  110. #define PM_ColourBox            (TAG_USER+60)   /* (UlONG) Filled rectangle (for palettes etc.)                                 */
  111. #define PM_ColorBox             PM_ColourBox    /* For Americans... */
  112. /*
  113. // Tags passed to MakeMenu
  114. */
  115.  
  116. #define PM_Item                 (TAG_USER+50)   /* (PopupMenu *) Item pointer from MakeItem                                     */
  117. #define PM_Dummy                (TAG_USER+51)   /* (void) Ignored.                                                              */
  118.  
  119. /*
  120. // Tags passed to MakeIDList
  121. */
  122.  
  123. #define PM_ExcludeID            (TAG_USER+55)   /* (ULONG) ID number of menu to deselect when this gets selected                */
  124. #define PM_IncludeID            (TAG_USER+56)   /* (ULONG) ID number of menu to select when this gets selected                  */
  125. #define PM_ReflectID            (TAG_USER+57)   /* (ULONG) ID number of menu that should reflect the state of this one          */
  126. #define PM_InverseID            (TAG_USER+58)   /* (ULONG) ID number of menu to inverse reflect the state of this one           */
  127.  
  128. /*
  129. // Tags for PM_InsertMenuItemA()
  130. */
  131.  
  132. #define PM_Insert_Before        (TAG_USER+200)  /* (BOOL) Insert before the item pointed to by the following argument   (N/A)   */
  133. #define PM_Insert_BeforeID      (TAG_USER+201)  /* (ULONG) Insert before the first item with ID equal to the argument           */
  134. #define PM_Insert_After         (TAG_USER+202)  /* (PopupMenu *) Insert after the item pointed to by the following argument     */
  135. #define PM_Insert_AfterID       (TAG_USER+203)  /* (ULONG) Insert after the first item with ID equal to the argument            */
  136. #define PM_Insert_Last          (TAG_USER+205)  /* (BOOL) Insert after the last item                                            */
  137. #define PM_Insert_First         (TAG_USER+209)  /* (BOOL) Insert after the first item (which is usually invisible)              */
  138. #define PM_InsertSub_First      (TAG_USER+206)  /* (PopupMenu *) Insert before the first item in the submenu                    */ 
  139. #define PM_InsertSub_Last       (TAG_USER+207)  /* (PopupMenu *) Insert at the and of a submenu                                 */
  140. #define PM_InsertSub_Sorted     (TAG_USER+208)  /* (PopupMenu *)                                                        (N/A)   */
  141. #define PM_Insert_Item          (TAG_USER+210)  /* (PopupMenu *) Item to insert, may be repeated for several items              */
  142.  
  143. /*
  144. // Layout methods
  145. */
  146.  
  147. #define PML_None                0               /* Normal item          */
  148. #define PML_Horizontal          1               /* Horizontal group     */
  149. #define PML_Vertical            2               /* Vertical group       */
  150. #define PML_Table               3               /* Table group          */
  151. #define PML_Default             255             /* Don't use            */
  152.  
  153. /*
  154. // Macros
  155. */
  156.  
  157. #define PMMenu(t)       PM_MakeMenu(\
  158.                         PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
  159.                         PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  160.                         PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  161.  
  162. #define PMMenuID(t)     PM_MakeMenu(\
  163.                         PM_Item, PM_MakeItem(PM_Hidden, TRUE, TAG_DONE),\
  164.                         PM_Item, PM_MakeItem(PM_TitleID, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  165.                         PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  166.  
  167. #define PMSubMenu(t)    PM_Sub, PM_MakeMenu(PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, TAG_DONE),\
  168.                         PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  169.  
  170. #define PMSimpleSub     PM_Sub, PM_MakeMenu(PM_Dummy, 0
  171. #define PMItem(t)       PM_Item, PM_MakeItem(PM_Title, t
  172. #define PMItemID(t)     PM_Item, PM_MakeItem(PM_TitleID, t
  173. #define PMInfo(t)       PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE
  174. #define PMColBox(c)     PM_Item, PM_MakeItem(PM_ColourBox, c
  175. #define PMBar           PM_Item, PM_MakeItem(PM_TitleBar, TRUE
  176. #define PMMenuTitle(t)  PM_Item, PM_MakeItem(PM_Title, t, PM_NoSelect, TRUE, PM_ShinePen, TRUE, PM_Shadowed, TRUE, PM_Center, TRUE, TAG_DONE),\
  177.                         PM_Item, PM_MakeItem(PM_WideTitleBar, TRUE, TAG_DONE)
  178. #define PMHoriz         PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Horizontal
  179. #define PMVert          PM_Item, PM_MakeItem(PM_NoSelect, TRUE, PM_LayoutMode, PML_Vertical
  180. #define PMMembers       PM_Members, PM_MakeMenu(PM_Dummy, 0
  181.  
  182. #define PMExcl          PM_Exclude, PM_MakeIDList(
  183. #define ExID(id)        PM_ExcludeID, id
  184. #define InID(id)        PM_IncludeID, id
  185. #define RefID(id)       PM_ReflectID, id
  186. #define InvID(id)       PM_InverseID, id
  187.  
  188. #define PMCheckItem(t,id)       PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE
  189.  
  190. #define PMMXItem(t,id)  PM_Item, PM_MakeItem(PM_Title, t, PM_ID, id, PM_Checkit, TRUE, PM_Toggle, FALSE
  191.  
  192. #define PMEnd           TAG_DONE)
  193.  
  194. #ifndef End
  195. #define End             TAG_DONE)
  196. #endif
  197.  
  198. #define PMERR           -5
  199.  
  200. /* For compatibility with old sources - DO NOT USE */
  201. #define PMTitleBar      PMBar
  202. #define PMNarrowBar     PMBar
  203. #define PMNarrowTitleBar PMBar
  204.  
  205. /*
  206. // Library base
  207. */
  208.  
  209. OBJECT PopupMenuBase
  210.     Library:Library,
  211.     SegList:ULONG,
  212.     Flags:ULONG,
  213.     ExecBase:PTR TO Library,          /* Theese library */
  214.     UtilityBase:PTR TO Library,       /* pointers are   */
  215.     IntuitionBase:PTR TO Library,     /* valid as long  */
  216.     GfxBase:PTR TO Library,           /* as pm lib      */
  217.     DOSBase:PTR TO Library,           /* is open.       */
  218.     NewPrefs:LONG,                    /* Reload prefs.  */
  219.     CxBase:PTR TO Library,            /* commodities.   */
  220.     LayersBase:PTR TO Library,        /* layers.library */
  221.     CyberGfxBase:PTR TO Library       /* cybergfx.lib   */
  222.  
  223. #define POPUPMENU_VERSION       10
  224. #define POPUPMENU_NAME          'popupmenu.library'
  225. #define OPEN_PM_LIB             (PopupMenuBase= OpenLibrary(POPUPMENU_NAME, POPUPMENU_VERSION))
  226. #define CLOSE_PM_LIB            if(PopupMenuBase) CloseLibrary((struct Library *)PopupMenuBase);
  227.  
  228. /*
  229. // PopupMenu structure
  230. //
  231. // Note:
  232. // This structure may change in future versions.
  233. // Do not read or write fields directly, use PM_Set/GetPopupMenuAttrs()
  234. */
  235.  
  236. OBJECT PopupMenu
  237.     Next:PTR TO PopupMenu,          /* Next item in menu */
  238.     [CUNION
  239.         Sub:PTR TO PopupMenu,
  240.         Group:PTR TO PopupMenu
  241.     ENDUNION],
  242.     [CUNION
  243.         Title:PTR TO UBYTE,
  244.         TitleID:ULONG,
  245.         Boopsi:PTR TO _Object
  246.     ENDUNION],
  247.     Flags:ULONG,          /* Flags */
  248.     ID:ULONG,             /* Item ID */
  249.     UserData:PTR,   /* UserData */
  250.     
  251.     Left:WORD,       /* Left pos of this item */
  252.     Top:WORD,        /* Top pos of this item */
  253.     Width:UWORD,      /* Width of this item */
  254.     Height:UWORD,     /* Height of this item */
  255.  
  256.         /* Very private and undocumented stuff follows. */
  257.         /* Mess with it at your own risk. */
  258.  
  259.     ExtFlags:UWORD,       /* Extended flags */
  260.  
  261.     Layout:UBYTE,         /* Layout mode */
  262.     CBox:UBYTE,          /* ColourBox pen */
  263.  
  264.     Exclude:PTR, // TO PM_IDLst,   /* Exclude/Included/Reflected items */
  265.     AutoSetPtr:PTR TO LONG, /* Ptr to BOOL containing current state */
  266.  
  267.     [CUNION
  268.         Images[2]:PTR TO Image, /* Images/Icons (0 - unselected, 1 - sel) */
  269.         IconID:PTR TO UBYTE
  270.     ENDUNION],
  271.  
  272.     CommKey:UBYTE,    /* Command Key */
  273.     Weight:UBYTE,     /* Weight */
  274.     SubConstruct:PTR TO Hook,  /* SubMenu Constructor hook */
  275.     SubDestruct:PTR TO Hook,   /* SubMenu Destructor hook */
  276.     TextPen:UBYTE,    /* Pen number for item's text */
  277.     Pad:UBYTE
  278.  
  279. /* Public flags for the PopupMenu->Header.Flags field */
  280.  
  281. #define PM_CHECKIT             $40000000
  282. #define PM_CHECKED             $80000000
  283.  
  284.